home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / HTML and CSS Modes / cssReadDialog.tcl < prev    next >
Encoding:
Text File  |  2001-01-12  |  23.3 KB  |  746 lines

  1. ## -*-Tcl-*-
  2.  # ###################################################################
  3.  #  CSS mode - tools for editing CSS documents
  4.  # 
  5.  #  FILE: "cssReadDialog.tcl"
  6.  #                                    created: 00-01-02 00.24.27 
  7.  #                                last update: 00-12-16 17.03.59 
  8.  #  Author: Johan Linde
  9.  #  E-mail: <alpha_www_tools@go.to>
  10.  #     www: <http://go.to/alpha_www_tools>
  11.  #  
  12.  # Version: 2.0
  13.  # 
  14.  # Copyright 1997-2001 by Johan Linde
  15.  #  
  16.  # This program is free software; you can redistribute it and/or modify
  17.  # it under the terms of the GNU General Public License as published by
  18.  # the Free Software Foundation; either version 2 of the License, or
  19.  # (at your option) any later version.
  20.  # 
  21.  # This program is distributed in the hope that it will be useful,
  22.  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23.  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24.  # GNU General Public License for more details.
  25.  # 
  26.  # You should have received a copy of the GNU General Public License
  27.  # along with this program; if not, write to the Free Software
  28.  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29.  # 
  30.  # ###################################################################
  31.  ##
  32.  
  33. #===============================================================================
  34. # This file contain procs for reading the CSS property dialogs.
  35. # For each type of property there is a proc
  36. # css::ReadDialog<type>
  37. #===============================================================================
  38.  
  39. #===============================================================================
  40. # ◊◊◊◊ Reading dialog values ◊◊◊◊ #
  41. #===============================================================================
  42.  
  43. # group
  44. proc css::ReadDialoggroup {group v ind imp ptext etext} {
  45.     upvar $v val $ind index $imp important $ptext proptext $etext errText
  46.     
  47.     global css::Group css::Property css::Descriptor css::IsDescriptor
  48.     foreach prop [set css::Group($group)] {
  49.         if {${css::IsDescriptor}} {
  50.             set p [set css::Descriptor($prop)]
  51.         } else {
  52.             set p [set css::Property($prop)]
  53.         }
  54.         set curr $proptext
  55.         eval css::ReadDialog$p $prop val index important proptext errText
  56.         if {[string length $proptext] > [string length $curr] && 
  57.         ([info exists important($prop)] || [info exists important($group)])} {
  58.             append proptext " ! important"
  59.         }
  60.     }
  61. }
  62.  
  63. # @charset
  64. proc css::ReadDialog@charset {prop v ind imp ptext etext} {
  65.     upvar $v val $ind index $ptext proptext
  66.     if {[set txt [string trim [lindex $val $index] "\" "]] != ""} {
  67.         append proptext ";\r$prop \"$txt\""
  68.     }
  69. }
  70.  
  71. # @import
  72. proc css::ReadDialog@import {prop v ind imp ptext etext} {
  73.     upvar $v val $ind index $ptext proptext
  74.     if {[set txt [css::ReadUrl val index]] != ""} {
  75.         append txt [css::ReadMediaList val index]
  76.         append proptext ";\r$prop$txt"
  77.     } else {
  78.         incr index 2
  79.     }
  80. }
  81.  
  82. # @media
  83. proc css::ReadDialog@media {prop v ind imp ptext etext} {
  84.     upvar $v val $ind index $ptext proptext
  85.     if {[set txt [css::ReadMediaList val index]] != ""} {
  86.         append proptext ";\r$prop$txt"
  87.     }
  88. }
  89.  
  90. # @page
  91. proc css::ReadDialog@page {prop v ind imp ptext etext} {
  92.     upvar $v val $ind index $ptext proptext
  93.     incr index
  94.     append proptext ";\r$prop [string trim [lindex $val [expr {$index - 1}]][css::ReadChoiceList 1 val index]]"
  95. }
  96.  
  97. # choices
  98. proc css::ReadDialogchoices {prop v ind imp ptext etext} {
  99.     upvar $v val $ind index $ptext proptext
  100.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  101.         append proptext ";\r$prop:$txt"
  102.     }
  103. }
  104.  
  105. # color
  106. proc css::ReadDialogcolor {prop v ind imp ptext etext} {
  107.     upvar $v val $ind index $ptext proptext $etext errtext
  108.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index 3]) || 
  109.     [set txt [css::ReadColor $prop val index errtext]] != ""} {
  110.         append proptext ";\r$prop:$txt"
  111.     }
  112. }
  113.  
  114. # url
  115. proc css::ReadDialogurl {prop v ind imp ptext etext} {
  116.     upvar $v val $ind index $ptext proptext
  117.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index 3]) || 
  118.     [set txt [css::ReadUrl val index]] != ""} {
  119.         append proptext ";\r$prop:$txt"
  120.     }
  121. }
  122.  
  123. # family = like font-family and voice-family
  124. proc css::ReadDialogfamily {prop v ind imp ptext etext} {
  125.     upvar $v val $ind index $ptext proptext
  126.     if {[set txt [css::ReadChoiceList 1 val index]] != " inherit"} {
  127.         set txt " [string trim [join [list [lindex $val $index] $txt] ,] " ,"]"
  128.     }
  129.     if {![is::Whitespace $txt]} {append proptext ";\r$prop:$txt"}
  130.     incr index 2
  131. }
  132.  
  133. # integer
  134. proc css::ReadDialoginteger {prop v ind imp ptext etext} {
  135.     upvar $v val $ind index $ptext proptext $etext errtext
  136.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index]) || 
  137.     [set txt [css::ReadNumberNoUnit $prop val index 0 1 errtext]] != ""} {
  138.         append proptext ";\r$prop:$txt"
  139.     }
  140. }
  141.  
  142. # number
  143. proc css::ReadDialognumber {prop v ind imp ptext etext} {
  144.     upvar $v val $ind index $ptext proptext $etext errtext
  145.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index]) || 
  146.     [set txt [css::ReadNumberNoUnit $prop val index 0 0 errtext]] != ""} {
  147.         append proptext ";\r$prop:$txt"
  148.     }
  149. }
  150.  
  151. # nlpc = number, length, percentage, or choices
  152. proc css::ReadDialognlpc {prop v ind imp ptext etext} {
  153.     upvar $v val $ind index $ptext proptext $etext errtext
  154.     css::ReadNumChoices $prop val index length 1 1 0 proptext errtext
  155. }
  156.  
  157. # lpc = length, percentage, or choices
  158. proc css::ReadDialoglpc {prop v ind imp ptext etext} {
  159.     upvar $v val $ind index $ptext proptext $etext errtext
  160.     css::ReadNumChoices $prop val index length 1 0 0 proptext errtext
  161. }
  162.  
  163. # npc = number, percentage, or choices
  164. proc css::ReadDialognpc {prop v ind imp ptext etext} {
  165.     upvar $v val $ind index $ptext proptext $etext errtext
  166.     css::ReadNumChoices $prop val index number 1 1 1 proptext errtext
  167. }
  168.  
  169. # lc = length or choices
  170. proc css::ReadDialoglc {prop v ind imp ptext etext} {
  171.     upvar $v val $ind index $ptext proptext $etext errtext
  172.     css::ReadNumChoices $prop val index length 0 0 0 proptext errtext
  173. }
  174.  
  175. # ac = angle or choices
  176. proc css::ReadDialogac {prop v ind imp ptext etext} {
  177.     upvar $v val $ind index $ptext proptext $etext errtext
  178.     css::ReadNumChoices $prop val index angle 0 0 0 proptext errtext
  179. }
  180.  
  181. # fc = frequency or choices
  182. proc css::ReadDialogfc {prop v ind imp ptext etext} {
  183.     upvar $v val $ind index $ptext proptext $etext errtext
  184.     css::ReadNumChoices $prop val index frequency 0 0 0 proptext errtext
  185. }
  186.  
  187. # cc = color or choices
  188. proc css::ReadDialogcc {prop v ind imp ptext etext} {
  189.     upvar $v val $ind index $ptext proptext $etext errtext
  190.     if {([set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 3]) || 
  191.     [set txt [css::ReadColor $prop val index errtext]] != ""} {
  192.         append proptext ";\r$prop:$txt"
  193.     }    
  194. }
  195.  
  196. # uc = url or choices
  197. proc css::ReadDialoguc {prop v ind imp ptext etext} {
  198.     upvar $v val $ind index $ptext proptext $etext errtext
  199.     if {([set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 3]) || 
  200.     [set txt [css::ReadUrl val index]] != ""} {
  201.         append proptext ";\r$prop:$txt"
  202.     }    
  203. }
  204.  
  205. # lp = length or percentage
  206. proc css::ReadDialoglp {prop v ind imp ptext etext} {
  207.     upvar $v val $ind index $ptext proptext $etext errtext
  208.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index 2]) || 
  209.     [set txt [css::ReadNumber $prop val index length 1 0 0 errtext]] != ""} {
  210.         append proptext ";\r$prop:$txt"
  211.     }    
  212. }
  213.  
  214. # tp = time or percentage
  215. proc css::ReadDialogtp {prop v ind imp ptext etext} {
  216.     upvar $v val $ind index $ptext proptext $etext errtext
  217.     if {([set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index 2]) || 
  218.     [set txt [css::ReadNumber $prop val index time 1 0 0 errtext]] != ""} {
  219.         append proptext ";\r$prop:$txt"
  220.     }    
  221. }
  222.  
  223. # ic = integer or choices
  224. proc css::ReadDialogic {prop v ind imp ptext etext} {
  225.     upvar $v val $ind index $ptext proptext $etext errtext
  226.     if {([set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 2]) || 
  227.     [set txt [css::ReadNumberNoUnit $prop val index 0 1 errtext]] != ""} {
  228.         append proptext ";\r$prop:$txt"
  229.     }    
  230. }
  231.  
  232. # nc = number or choices
  233. proc css::ReadDialognc {prop v ind imp ptext etext} {
  234.     upvar $v val $ind index $ptext proptext $etext errtext
  235.     if {([set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 2]) || 
  236.     [set txt [css::ReadNumberNoUnit $prop val index 0 0 errtext]] != ""} {
  237.         append proptext ";\r$prop:$txt"
  238.     }    
  239. }
  240.  
  241. # border
  242. proc css::ReadDialogborder {prop v ind imp ptext etext} {
  243.     upvar $v val $ind index $imp important $ptext proptext $etext errtext
  244.     css::ReadDialoggroup $prop val index important proptext errtext
  245.     regsub -all -- "-top-" $proptext "-" proptext
  246. }
  247.  
  248. # clip
  249. proc css::ReadDialogclip {prop v ind imp ptext etext} {
  250.     upvar $v val $ind index $ptext proptext $etext errtext
  251.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  252.         incr index 12
  253.         append proptext ";\rclip:$txt"
  254.     } else {
  255.         set txt ""
  256.         for {set i 0} {$i < 4} {incr i} {
  257.             if {([set txt1 [css::ReadChoiceList 0 val index auto]] != "" && [incr index 2]) || 
  258.             [set txt1 [css::ReadNumber clip val index length 0 0 0 errtext]] != ""} {
  259.                 append txt $txt1
  260.             }
  261.         }
  262.         if {[llength $txt]} {
  263.             if {[llength $txt] != 4} {
  264.                 lappend errtext "clip: All four sides must be specified."
  265.             } else {
  266.                 append proptext ";\rclip: rect([join $txt ", "])"
  267.             }
  268.         }
  269.     }
  270. }
  271.  
  272. # quotes
  273. proc css::ReadDialogquotes {prop v ind imp ptext etext} {
  274.     upvar $v val $ind index $ptext proptext $etext errtext
  275.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  276.         append proptext ";\r$prop:$txt"
  277.     } elseif {[set txt [string trim [lindex $val [incr index 3]]]] != ""} {
  278.         if {![regexp {^(('[^']+'|\"[^\"]+\")[ \t\r\n]+('[^']+'|\"[^\"]+\")[ \t\r\n]+)+$} "$txt "]} {
  279.             lappend errtext "$prop: An even number of strings required."
  280.         } else {
  281.             append proptext ";\r$prop: $txt"
  282.         }
  283.     }
  284.     incr index
  285. }
  286.  
  287. # counter
  288. proc css::ReadDialogcounter {prop v ind imp ptext etext} {
  289.     upvar $v val $ind index $ptext proptext $etext errtext
  290.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  291.         append proptext ";\r$prop:$txt"
  292.     } elseif {[set txt [string trim [lindex $val $index]]] != ""} {
  293.         if {![regexp {^([^-0-9][^ \t\r\n]*([ \t\r\n]+[-\+]?[0-9]+)?[ \t\r\n]+)+$} "$txt "]} {
  294.             lappend errtext "$prop: Incorrect data."
  295.         } else {
  296.             append proptext ";\r$prop: $txt"
  297.         }
  298.     }
  299.     incr index
  300. }
  301.  
  302. # size
  303. proc css::ReadDialogsize {prop v ind imp ptext etext} {
  304.     upvar $v val $ind index $ptext proptext $etext errtext
  305.     if {([set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 4]) || 
  306.     [set txt "[css::ReadNumber $prop val index length 0 0 0 errtext][css::ReadNumber $prop val index length 0 0 0 errtext]"] != ""} {
  307.         append proptext ";\r$prop:$txt"
  308.     }
  309. }
  310.  
  311. # content
  312. proc css::ReadDialogcontent {prop v ind imp ptext etext} {
  313.     upvar $v val $ind index $ptext proptext $etext errtext
  314.     if {[set txt [css::ReadChoiceList 1 val index]] == "inherit"} {
  315.         append proptext ";\r$prop:$txt"
  316.     } elseif {[append txt " " [lindex $val $index]] != " "} {
  317.         append proptext ";\r$prop: [string trim $txt]"
  318.     }
  319. }
  320.  
  321. # marks
  322. proc css::ReadDialogmarks {prop v ind imp ptext etext} {
  323.     upvar $v val $ind index $ptext proptext $etext errtext
  324.     if {[set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 2]} {
  325.         append proptext ";\r$prop:$txt"
  326.     } else {
  327.         if {[lindex $val $index]} {set txt crop}
  328.         if {[lindex $val [expr {$index + 1}]]} {append txt " cross"}
  329.         incr index 2
  330.         if {$txt != ""} {append proptext ";\r$prop: [string trim $txt]"}
  331.     }
  332. }
  333.  
  334. # page
  335. proc css::ReadDialogpage {prop v ind imp ptext etext} {
  336.     upvar $v val $ind index $ptext proptext $etext errtext
  337.     if {[lindex $val $index]} {
  338.         append proptext ";\rpage: auto"
  339.     } elseif {[set txt [string trim [lindex $val [incr index]]]] != ""} {
  340.         if {![regexp {^[^-0-9][^ \t\r\n]*$} $txt]} {
  341.             lappend errtext "$prop: Invalid indentifier: $txt"
  342.         } else {
  343.             append proptext ";\rpage: $txt"
  344.         }
  345.     }
  346. }
  347.  
  348. # backpos
  349. proc css::ReadDialogbackpos {prop v ind imp ptext etext} {
  350.     upvar $v val $ind index $ptext proptext $etext errtext
  351.     if {[lindex $val $index] && [incr index 7]} {
  352.         append proptext ";\r$prop: inherit"
  353.     } elseif {[incr index] && [llength [set txt "[css::ReadChoiceList 1 val index][css::ReadChoiceList 1 val index]"]] == 2} {
  354.         append proptext ";\r$prop:$txt"
  355.     } elseif {[set txt2 "[css::ReadNumber $prop val index length 1 0 0 errtext][css::ReadNumber $prop val index length 1 0 0 errtext]"] != ""} {
  356.         if {[llength $txt2] == 2} {
  357.             set p1 [regexp % [lindex $txt2 0]]
  358.             set p2 [regexp % [lindex $txt2 1]]
  359.             if {$p1 && !$p2 || !$p1 && $p2} {
  360.                 lappend errtext "$prop: Mixing length and percentage not allowed,$txt2"
  361.             } else {
  362.                 append proptext ";\r$prop:$txt2"
  363.             }
  364.         } else {
  365.             append proptext ";\r$prop:$txt2"
  366.         }            
  367.     } elseif {[llength $txt] == 1} {
  368.         lappend errtext "$prop: Both sides must be specified, not only '[string trim $txt]'."
  369.     }
  370. }
  371.  
  372. # fontstyle
  373. proc css::ReadDialogfontstyle {prop v ind imp ptext etext} {
  374.     upvar $v val $ind index $ptext proptext $etext errtext
  375.     global css::Choices
  376.     if {[lindex $val [expr {$index + 3}]] && [incr index 4]} {
  377.         append proptext ";\r$prop: all"
  378.     } else {
  379.         set txt [string trim "[css::ReadChoiceList 1 val index], [lindex $val $index]" ", "]
  380.         incr index 3
  381.         foreach c [split $txt ,] {
  382.             if {![lcontains css::Choices($prop) [string trim $c]]} {
  383.                 append tmperr $c
  384.             }
  385.         }
  386.         if {[info exists tmperr]} {
  387.             lappend errtext "$prop: Incorrect descriptor(s), $tmperr"
  388.         } elseif {$txt != ""} {
  389.             append proptext ";\r$prop: $txt"
  390.         }
  391.     }
  392. }
  393.  
  394. # fontvariant
  395. proc css::ReadDialogfontvariant {prop v ind imp ptext etext} {
  396.     upvar $v val $ind index $ptext proptext $etext errtext
  397.     global css::Choices
  398.     set txt [string trim "[css::ReadChoiceList 1 val index], [lindex $val $index]" ", "]
  399.     incr index 2
  400.     foreach c [split $txt ,] {
  401.         if {![lcontains css::Choices($prop) [string trim $c]]} {
  402.             append tmperr $c
  403.         }
  404.     }
  405.     if {[info exists tmperr]} {
  406.         lappend errtext "$prop: Incorrect descriptor(s), $tmperr"
  407.     } elseif {$txt != ""} {
  408.         append proptext ";\r$prop: $txt"
  409.     }
  410. }
  411.  
  412. # fontsize
  413. proc css::ReadDialogfontsize {prop v ind imp ptext etext} {
  414.     upvar $v val $ind index $ptext proptext $etext errtext
  415.     if {[lindex $val [expr {$index  + 2}]] && [incr index 4]} {
  416.         append proptext ";\r$prop: all"
  417.     } else {
  418.         set txt [string trim "[css::ReadNumber $prop val index length 0 0 0 errtext], [lindex $val [expr {$index + 1}]]" ", "]
  419.         incr index 2
  420.         foreach c [split $txt ,] {
  421.             if {[catch {css::CheckNumber $prop length [string trim $c] "" 0 0 0}]} {
  422.                 append tmperr $c
  423.             }
  424.         }
  425.         if {[info exists tmperr]} {
  426.             lappend errtext "$prop: Incorrect descriptor(s), $tmperr"
  427.         } elseif {$txt != ""} {
  428.             append proptext ";\r$prop: $txt"
  429.         }
  430.     }
  431. }
  432.  
  433. # panose
  434. proc css::ReadDialogpanose {prop v ind imp ptext etext} {
  435.     upvar $v val $ind index $ptext proptext $etext errtext
  436.     for {set i 0} {$i < 10} {incr i} {
  437.         append txt [css::ReadNumberNoUnit $prop val index 0 1 errtext]
  438.     }
  439.     if {[llength $txt] && [llength $txt] != 10} {
  440.         lappend errtext "$prop: All 10 numbers must be specified"
  441.     } elseif {[llength $txt]} {
  442.         append proptext ";\r$prop:$txt"
  443.     }
  444. }
  445.  
  446. # widths
  447. proc css::ReadDialogwidths {prop v ind imp ptext etext} {
  448.     upvar $v val $ind index $ptext proptext $etext errtext
  449.     set vlist [split [string toupper [string trim [lindex $val $index]]] ,]
  450.     set err ""; set vv ""
  451.     foreach u $vlist {
  452.         set e 0
  453.         set ur [lindex [string trim $u] 0]
  454.         if {![css::CheckUrange $ur] && ![regexp {^[0-9]+$} $ur]} {
  455.             set e 1
  456.             lappend err $ur
  457.         } 
  458.         foreach n [lrange $u 1 end] {
  459.             if {![regexp {^[0-9]+$} $n]} {lappend err $n}
  460.         }
  461.         append vv ", [string trim $u]"
  462.         if {!$e && [llength $u] == 1 && ![regexp {^[0-9]+$} $ur]} {
  463.             lappend err $u
  464.         }
  465.     }
  466.     if {[llength $vlist]} {append proptext ";\r$prop:[string trimleft $vv ,]"}
  467.     if {$err != ""} {lappend errtext "$prop: [join $err]"}
  468.     incr index
  469. }
  470.  
  471. # bbox
  472. proc css::ReadDialogbbox {prop v ind imp ptext etext} {
  473.     upvar $v val $ind index $ptext proptext $etext errtext
  474.     set n 0
  475.     set orgerr $errtext
  476.     for {set i 0} {$i < 4} {incr i} {
  477.         set txt [css::ReadNumberNoUnit $prop val index 0 1 errtext]
  478.         if {$txt != ""} {incr n}
  479.         lappend t $txt
  480.     }
  481.     if {$n == 4} {
  482.         append proptext ";\r$prop:[join $t ","]"
  483.     } elseif {$n && $orgerr == $errtext} {
  484.         lappend errtext "$prop: All for numbers must be specified."
  485.     }
  486. }
  487.  
  488. # unirange
  489. proc css::ReadDialogunirange {prop v ind imp ptext etext} {
  490.     upvar $v val $ind index $ptext proptext $etext errtext
  491.     set vlist [split [string toupper [string trim [lindex $val $index]]] ,]
  492.     set err ""; set vv ""
  493.     foreach u $vlist {
  494.         if {![css::CheckUrange [string trim $u]]} {
  495.             lappend err $u
  496.         } else {
  497.             append vv ", [string trim $u]"
  498.         }
  499.     }
  500.     if {[llength $vlist]} {append proptext ";\r$prop:[string trimleft $vv ,]"}
  501.     if {$err != ""} {lappend errtext "$prop: [join $err]"}
  502.     incr index
  503. }
  504.  
  505. # src
  506. proc css::ReadDialogsrc {prop v ind imp ptext etext} {
  507.     upvar $v val $ind index $ptext proptext $etext errtext
  508.     set src [set src0 [string trim [lindex $val [incr index 6]]]]
  509.     incr index
  510.     if {$src == ""} {return}
  511.     while {[regsub -nocase {^((url\([ \t\r\n]*("[^"]+"|'[^']+'|[^"' \t\r\n]+)[ \t\r\n]*\)[ \t\r\n]*format\(("[^"]+"|'[^']+')([ \t\r\n]*,[ \t\r\n]("[^"]+"|'[^']+'))*\))|local\(("[^"]+"|'[^']+')\)),?[ \t\r\n]*} $src "" src]} {
  512.     }
  513.     if {$src != ""} {
  514.         lappend errtext "$prop: $src"
  515.     } else {
  516.         append proptext ";\r$prop: $src0"
  517.     }
  518. }
  519.  
  520. # textalign
  521. proc css::ReadDialogtextalign {prop v ind imp ptext etext} {
  522.     upvar $v val $ind index $ptext proptext $etext errtext
  523.     global css::Choices
  524.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  525.         append proptext ";\r$prop:$txt"
  526.     } elseif {[set txt [string trim [lindex $val $index]]] != ""} {
  527.         set txt [css::QuoteValue $txt]
  528.         append proptext ";\r$prop: $txt"
  529.     }
  530.     incr index
  531. }
  532.  
  533. # textdecoration
  534. proc css::ReadDialogtextdecoration {prop v ind imp ptext etext} {
  535.     upvar $v val $ind index $ptext proptext $etext errtext
  536.     global css::Choices
  537.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  538.         append proptext ";\r$prop:$txt"
  539.     } else {
  540.         for {set i 0} {$i < 4} {incr i} {
  541.             if {[lindex $val [expr {$index + $i}]]} {
  542.                 append txt " " [lindex [set css::Choices($prop)] $i]
  543.             }
  544.         }
  545.         if {$txt != ""} {
  546.             append proptext ";\r$prop:$txt"
  547.         }
  548.     }
  549.     incr index 4
  550. }
  551.  
  552. # textshadow
  553. proc css::ReadDialogtextshadow {prop v ind imp ptext etext} {
  554.     upvar $v val $ind index $ptext proptext
  555.     if {[set txt [css::ReadChoiceList 1 val index]] != ""} {
  556.         append proptext ";\r$prop:$txt"
  557.     } else {
  558.         set txt [lindex $val [expr {$index + 10}]]
  559.         if {$txt != ""} {append proptext ";\r$prop: $txt"}
  560.     }
  561. }
  562.  
  563. # borderspacing
  564. proc css::ReadDialogborderspacing {prop v ind imp ptext etext} {
  565.     upvar $v val $ind index $ptext proptext $etext errtext
  566.     if {[set txt [css::ReadChoiceList 0 val index inherit]] != "" && [incr index 4]} {
  567.         append proptext ";\r$prop:$txt"
  568.     } else {
  569.         set err ""
  570.         set txt [css::ReadNumber $prop val index length 0 0 0 err]
  571.         append txt [css::ReadNumber $prop val index length 0 0 0 err]
  572.         if {$txt != "" && $err == ""} {
  573.             append proptext ";\r$prop:$txt"
  574.         } elseif {$err != ""} {
  575.             eval lappend errtext $err
  576.         }
  577.     } 
  578. }
  579.  
  580. # cursor
  581. proc css::ReadDialogcursor {prop v ind imp ptext etext} {
  582.     upvar $v val $ind index $ptext proptext $etext errtext
  583.     incr index 5
  584.     if {[set txt [css::ReadChoiceList 1 val index]] == " inherit" && [incr index]} {
  585.         append proptext ";\r$prop:$txt"
  586.     } else {
  587.         incr index -6
  588.         set url [css::ReadUrl val index]
  589.         set eurl0 [set eurl [string trim [lindex $val $index]]]
  590.         while {[regsub -nocase {^url\([ \t\r\n]*("[^"]+"|'[^']+'|[^"' \t\r\n]+)[ \t\r\n]*\)[ \t\r\n]*(,[ \t\r\n]*|[ \t\r\n]*$)} $eurl0 "" eurl0]} {
  591.         }
  592.         if {$eurl0 != ""} {
  593.             lappend errtext "$prop: $eurl0"
  594.         }
  595.         if {[set eurl [string trim [lindex $val $index]]] != ""} {
  596.             append url ", $eurl"
  597.         }
  598.         if {$url != "" && $txt == ""} {
  599.             lappend errtext "$prop: A generic cursor is required."
  600.         } else {
  601.             append proptext ";\r$prop:[string trimleft $url,$txt ,]"
  602.         }
  603.     }
  604. }
  605.  
  606. # playduring
  607. proc css::ReadDialogplayduring {prop v ind imp ptext etext} {
  608.     upvar $v val $ind index $ptext proptext
  609.     if {[set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 5]} {
  610.         append proptext ";\r$prop:$txt"
  611.     } elseif {[set txt [css::ReadUrl val index]] != ""} {
  612.         if {[lindex $val $index]} {lappend txt mix}
  613.         incr index
  614.         if {[lindex $val $index]} {lappend txt repeat}
  615.         incr index
  616.         append proptext ";\r$prop:$txt"        
  617.     } else {
  618.         incr index 2
  619.     }
  620. }
  621.  
  622. # azimuth
  623. proc css::ReadDialogazimuth {prop v ind imp ptext etext} {
  624.     upvar $v val $ind index $ptext proptext $etext errtext
  625.     if {[set txt [css::ReadChoiceList 1 val index]] != "" && [incr index 4]} {
  626.         append proptext ";\r$prop:$txt"
  627.     } elseif {[set txt [css::ReadNumber $prop val index angle 0 0 0 errtext]] != "" && [incr index 2]} {
  628.         append proptext ";\r$prop:$txt"
  629.     } else {
  630.         set txt [css::ReadChoiceList 1 val index]
  631.         if {[lindex $val $index]} {append txt " behind"}
  632.         if {$txt != ""} {
  633.             append proptext ";\r$prop:$txt"
  634.         }
  635.         incr index
  636.     }
  637. }
  638.  
  639. proc css::ReadAllValuesBox {v} {
  640.     upvar $v val
  641.     global css::SetAllValues
  642.     set css::SetAllValues [lindex $val [expr {[llength $val] - 4}]]
  643. }
  644.  
  645. #===============================================================================
  646. # ◊◊◊◊ Dialog reading help procs ◊◊◊◊ #
  647. #===============================================================================
  648.  
  649. proc css::ReadChoiceList {choices v ind args} {
  650.     upvar $v val $ind index
  651.     
  652.     global css::IsDescriptor
  653.     if {${css::IsDescriptor} && !$choices} {return}
  654.     set txt ""
  655.     if {$choices} {
  656.         if {[set c [lindex $val $index]] != " "} {
  657.             set txt " $c"
  658.         }
  659.     } elseif {[lindex $val $index]} {
  660.         append txt " $args"
  661.     }
  662.     incr index
  663.     return $txt
  664. }
  665.  
  666. proc css::ReadColor {prop v ind err} {
  667.     upvar $v val $ind index $err errtext
  668.     set txt ""
  669.     if {[set ctxt [string trim [lindex $val $index]]] != ""} {
  670.         if {[catch {css::CheckColorNumber $ctxt} col]} {
  671.             lappend errtext "$prop: $ctxt is not a valid color."
  672.         } else {
  673.             set txt " $col"
  674.         }
  675.     } elseif {[set cval [lindex $val [expr {$index + 1}]]] != " "} {
  676.         set txt " [css::CheckColorNumber $cval]"
  677.     }
  678.     incr index 3
  679.     return $txt
  680. }
  681.  
  682. proc css::ReadUrl {v ind} {
  683.     upvar $v val $ind index
  684.     set txt ""
  685.     if {[set url [string trim [lindex $val $index]]] != "" || 
  686.     [set url [lindex $val [expr {$index + 1}]]] != " "} {
  687.         set txt " url(\"[html::URLescape2 $url]\")"
  688.         html::AddToCache URLs $url
  689.     }
  690.     incr index 3
  691.     return $txt
  692. }
  693.  
  694. proc css::ReadNumChoices {prop v ind type percent number integer ptext etext} {
  695.     upvar $v val $ind index $ptext proptext $etext errtext
  696.     global css::Choices
  697.     if {([set txt [css::ReadChoiceList 1  val index [set css::Choices($prop)]]] != "" && [incr index 2]) || 
  698.     [set txt [css::ReadNumber $prop val index $type $percent $number $integer errtext]] != ""} {
  699.         append proptext ";\r$prop:$txt"
  700.     }
  701. }
  702.  
  703. proc css::ReadNumber {prop v ind type percent number integer etext} {
  704.     upvar $v val $ind index $etext errtext
  705.     set txt ""
  706.     if {[set n [string trim [lindex $val $index]]] != ""} {
  707.         regsub -all " " $n "" n
  708.         if {[catch {css::CheckNumber $prop $type $n [lindex $val [expr {$index + 1}]] $percent $number $integer} res]} {
  709.             lappend errtext "$prop: $res"
  710.         } else {
  711.             set txt " $res"
  712.         }
  713.     }
  714.     incr index 2
  715.     return $txt
  716. }
  717.  
  718. proc css::ReadNumberNoUnit {prop v ind percent integer etext} {
  719.     upvar $v val $ind index $etext errtext
  720.     set txt ""
  721.     if {[set n [string trim [lindex $val $index]]] != ""} {
  722.         if {[catch {css::CheckNumber $prop "" $n " " $percent 1 $integer} res]} {
  723.             lappend errtext "$prop: $res"
  724.         } else {
  725.             set txt " $res"
  726.         }
  727.     }
  728.     incr index
  729.     return $txt
  730. }
  731.  
  732. proc css::ReadMediaList {v ind} {
  733.     upvar $v val $ind index
  734.     global HTMLmodeVars
  735.     set txt " [string trim [join [list [css::ReadChoiceList 1 val index] " [lindex $val $index]"] ,] " ,"]"
  736.     foreach t [split $txt ,] {
  737.         set t [string tolower [string trim $t]]
  738.         if {![lcontains HTMLmodeVars(mediatypes) $t]} {
  739.             lappend HTMLmodeVars(mediatypes) $t
  740.             prefs::modifiedModeVar mediatypes HTML
  741.         }
  742.     }
  743.     incr index
  744.     return [string trimright $txt]
  745. }
  746.